import 'package:yp/services/api.dart';
import 'package:get/get.dart';
import 'package:sp_util/sp_util.dart';

import 'state.dart';

class GetPointsMethodLogic extends GetxController {
  final GetPointsMethodState state = GetPointsMethodState();
  
  @override
  void onInit() {
    // TODO: implement onInit
    super.onInit();
    getHowToGetPointsMethod();
  }

  /// 如何获得积分
  void getHowToGetPointsMethod() {
    Map<String, dynamic> params = {
      "access_token": SpUtil.getString("token"),
      "ec_key": "ec.menberpoints.illustrate"
    };
    Api.getHowToGetPointsMethod(params).listen((event) {
      print("如何获得积分的event：$event");
      if (event["code"] == 0) {
        List list = event["info_list"];
        if (list != null && list.length > 0) {
          state.infoMap = list.first;
          update();
        }
      }
    });
  }
  
}
